package com.example.mysaat.service_menu_manual_test.Listeners;

import android.app.Activity;
import android.widget.SeekBar;

public class MySeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
    private Activity activity = null;
    private boolean isReverse = false;
    public MySeekBarChangeListener(Activity activity){
            this.activity = activity;
    }

    public MySeekBarChangeListener(Activity activity,boolean reverse){
        this.activity = activity;
        this.isReverse = reverse;
    }
    private int value = 0;
    @Override
    public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
        value = i;
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {

    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        if(isReverse){
            if(value>3)
        seekBar.setProgress(100);
            else
            this.activity.finish();
        }else {
            if(value<99)
                seekBar.setProgress(0);
            else
                this.activity.finish();//直接finish()，将activity结束并弹出栈
        }
    }
}
